package cm.day06.Test1;

public class Studnent {
    private String name;
    private  String sex;
    private int age;

    public Studnent() {
    }

    public Studnent(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {


        if (sex=="男"&&sex=="女") {
            this.sex = sex;
        }else {
            try {
                throw new AgeException("性别异常");
            } catch (AgeException e) {
                e.printStackTrace();
            }
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>=15&&age<=50) {
            this.age = age;
        }else {
            try {
                throw new SexException("年龄异常");
            }catch (SexException e){
                e.printStackTrace();
            }
        }
    }
}
